<?php
namespace App\Service;

use App\Models\Order;
use App\Models\User;
use App\Models\UserAddress;

class OrderService
{
    public function store(User $user, UserAddress $address, $time, $message)
    {
        $order = $user->orders()->make([
            'address'   => [
                'province'   => $address->province_id,
                'city'       => $address->city_id,
                'district'   => $address->district_id,
                'address'       => $address->address,
                'full_address'  => $address->full_address,
                'contact_name'  => $address->contact_name,
                'contact_phone' => $address->contact_phone,
            ],
            'order_time'=> $time,
            'message'   => $message,
        ]);

        $order->save();
    }
}
